Category: Geeks r Us
Hi All:
Rosie needs a little help with some scripting for her website. I have an alert for younger site visitors, that looks like this:
<html> <HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function getName() {
var name1 = prompt("What is your name?", "")
var age = prompt("How old are you?", "")
if( age <= 12) {
alert("Sorry, little one...You're only " + age + " and can't come in now!" + name1 + ", but there is a place here just for you!")
window.open("http://www.crimsonsoul.net/ssl/playground.html")
} else {
alert("Hello " + name1 + "! Welcome to Crimson Soul! Since you are " + age + ", you can proceed!!!")
}
}
// End -->
</SCRIPT>
<BODY onLoad="getName()">
</html>
The thing is, I don't want older repeat visitors to have to complete this age check every time they access the pages where this script in implemented. Is there a way I can ensure that they don't have to do this?
Thanks!
NativeRose
Is their some way that you could have it log the users external IP? I have no idea if this is even possible, since I don't know a thing about javascript, but that's the idea that I have. Granted, they would have to enter the page again if their external IP changed, but that could be a temporary solution.
I've heard of persistence by using cookies from JavaScript, but I don't know how that would work...I know it can be done, though. Oh, and by the way, you forgot to close your <body> tag...and also, it's common practice to end your JavaScript statements with semicolons, like this:
var name1=prompt("What is your name?", "");
oh lol, did I forget to end it with a semicolon? silly me! I always wondered why they call them cookies anyway. I mean, cookies are supposed to be eaten, not used to store a computer user's information. Just a random thought...